import os
#import sys
#reload(sys)
#sys.setdefaultencoding('utf-8')
from datetime import timedelta

basedir = os.path.abspath(os.path.dirname(__file__))


class Config:
    JWT_SECRET_KEY = os.environ.get('SECRET_KEY') or 'adhsiujfdajksfjkahfg'
    JWT_ACCESS_TOKEN_EXPIRES = timedelta(minutes=30)
    JWT_REFRESH_TOKEN_EXPIRES = timedelta(days=7)
    JWT_TOKEN_LOCATION = ['headers']
    JWT_HEADER_NAME = 'HldzToken'
    JWT_HEADER_TYPE = 'Bearer'
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    SQLALCHEMY_TRACK_MODIFICATIONS = True
    # FLASKY_MAIL_SUBJECT_PREFIX = '[Flasky]'
    # FLASKY_MAIL_SENDER = '2442754800@qq.com'

    @staticmethod
    def init_app(app):
        pass

class DevelopmentConfig(Config):
    DEBUG = True
    # MAIL_SERVER = 'smtp.qq.com'
    # MAIL_PORT = 587
    # MAIL_USE_TLS = True
    # MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
    # MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
    SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URI') or \
                              'mysql+mysqlconnector://root:root@127.0.0.1:3306/hldz_auth?charset=utf8&auth_plugin=mysql_native_password'

class TestingConfig(Config):
    TESTING = False
    SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URI') or \
                              'mysql+mysqlconnector://root:root@127.0.0.1:3306/hldz_auth?charset=utf8&auth_plugin=mysql_native_password'

class ProductionConfig(Config):
    SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URI') or \
                              'mysql+mysqlconnector://user:123456@127.0.0.1:3306/hldz_auth?charset=utf8&auth_plugin=mysql_native_password'


config = {
    'development': DevelopmentConfig,
    'testing': TestingConfig,
    'production': ProductionConfig,
    'default': DevelopmentConfig
}
